package edu.towson.cosc490.incaseofemergency;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WeatherLink extends Activity {

	private WebView webView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_weather_link);
	    webView = (WebView) findViewById(R.id.webViewNotification);
	    openBrowser();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.weather_link, menu);
		return true;
	}
	
	private void openBrowser() {
		Intent intent = getIntent();
		String urlText = intent.getStringExtra("url");
		webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
		//webView.getSettings().setJavaScriptEnabled(true);
		//webView.loadUrl(urlText);
		
		
		
		MyWebViewClient webViewClient = new MyWebViewClient();
		
		webView.setWebViewClient(webViewClient);
		webViewClient.shouldOverrideUrlLoading(webView, urlText);
		
	   }
	
	private class MyWebViewClient extends WebViewClient {
	    @Override
	    public boolean shouldOverrideUrlLoading(WebView view, String url) {
	        view.loadUrl(url);
	        return true;
	    }
	}

}
